<template>
	<view class="mainbgc">
		<header-top :messageInfo="{typeFlag:true,message:'选择支付方式',liner:false}"></header-top>
		<!-- 现金 -->
		<view class="huisetext">现金</view>
		<!-- 选择方式 -->
		<view class="flexbetween ffffff mainpadding">
			<view class="strongtext">统一</view>
			<!-- <view class="xuanzebtn">选择</view> -->
		</view>
		<!-- 银行 -->
		<view class="huisetext">其他支付方式</view>
		<!-- 选择银行 -->
		<view class="mainpadding ffffff">
			<view class="flexbetween xiabiank  margin_top" v-for="item in paywayList" :key="item.id">
				<view class="strongtext">{{item.account_name}}</view>
				<view class="xuanzebtn" @click="selectPay(item)">选择</view>
			</view>
		</view>
		<template v-if="customers_id!=''">
			<!-- 银行 -->
			<view class="huisetext">预收款账户</view>
			<!-- 选择银行 -->
			<view class="mainpadding ffffff">
				<view class="flexbetween xiabiank  margin_top" v-for="item in yushou" :key="item.id">
					<view class="strongtext">{{item.account_name}}(￥{{item.money}})</view>
					<view class="xuanzebtn" @click="selectPay(item)">选择</view>
				</view>
			</view>
		</template>
		

	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				paywayList: [{
					account_coding: "",
					account_name: "",
					balance: 0,
					id: 0,
					is_default: "0",
				}],
				customers_id:"",
				yushou:[
					{
						account_coding: "ZH005",
						account_name: "预收款2",
						id: 5,
						money: "0.00",
					}
				]
			}
		},
		onLoad(options) {
			if(options.customers_id){
				this.customers_id = options.customers_id
			}
		},
		onShow() {
			this.getpayway()
			if(this.customers_id!=""){
				this.yushoukuanList()
			}
			
		},
		methods: {
			getpayway() {
				httpRequest.request('appapi/manage/index/accounts', 'POST', {
					is_default:0
				}, false, false, true).then(res => {
					this.paywayList = res.data
				}).catch(err => {
					// httpRequest.toast(err.msg);
				})
			},
			yushoukuanList(){
				httpRequest.request('appapi/manage/finance/collection_advance_account', 'POST', {
					customers_id: this.customers_id//客户id
				}, false, false, true).then(res => {
					this.yushou = res.data
				}).catch(err => {
					// httpRequest.toast(err.msg);
				})
			},
			selectPay(item){
				uni.$emit('getselectWay',item)
				uni.navigateBack(1)
			},
		}
	}
</script>

<style lang="scss" scoped>
	.xiabiank {
		padding-bottom: 30rpx;
		border-bottom: 1rpx solid rgba(0, 0, 0, .02);
	}

	.margin_top:first-child {
		margin-top: 0;
	}

	.huisetext {
		padding: 30rpx;
		font-size: 24rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #666666;
	}

	.xuanzebtn {
		font-size: 24rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #0BBDCB;
		width: 86rpx;
		height: 40rpx;
		background: rgba(11, 189, 203, .1);
		border-radius: 134rpx;
	}
</style>
